const api = require("../../../utils/interface.js")
Page({ 
  /**
   * 页面的初始数据
   */
  data: {
    phone: "",
    state: false,
    userId: "",
    list: [],
    listState: 1
  },
  
  gopassword() {
    wx.navigateTo({
      url: '/pages/userset/password/password'
    })
  },
  goList() {
    wx.navigateTo({
      url: '/pages/userset/accountList/accountList',
    })
  },
  onLoad: function(options) {
    this.getUserinfo()
  },
  changePhone(){
    wx.navigateTo({
      url: '/pages/userset/changephone/changephone',
    })
  },
  // 获取用户头像昵称
  getUserinfo(e) {
    let user = wx.getStorageSync('userInfo')
    api.getMemberInfo({
      id: user.id
    }).then(res => {
      this.setData({
        phone: res.data.result.phone
      })
    })
  },
  getAccountList() {
    let user = wx.getStorageSync('openid')
    console.log(user)
    api.getMemberInfoListByOpenId({
      openId: user
    }).then(res => {
      console.log(res)
      if (res.data.result.length > 1) {
        this.setData({
          listState: 2
        })
      } else {
        this.setData({
          listState: 3
        })
      }
      this.setData({
        list: res.data.result
      })
    })
  }
})